const express = require('express')
const router = express.Router()

const result=require('../db/result')

router.get('/getWebsite', (req, res) => {
    let sql="select * from website"
    result(sql,res)
})

router.get('/getWebsiteDetailPage/:websiteId',(req,res)=>{
    // console.log(req.params.pageId)
    const websiteId=req.params.websiteId
    let sql=`select * from website where websiteId=${websiteId}`
    console.log(sql)
    result(sql,res)
})

router.post('/getChecked',(req,res)=>{
    console.log(req.body)
    const params=req.body
    let sql=`select * from website where name in (`

    for(let i=0; i<params.length;i++){
        if(i!==params.length-1){
            sql+=`'${params[i]}',`
        }else{
            sql+=`'${params[i]}')`
        }
    }
    console.log(sql)
    result(sql,res)
})
module.exports=router